package com.example.checkin.vn.hotel;

import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Window;
import com.example.checkin.vn.R;
import com.example.checkin.vn.adapter.PullToZoomScrollView;
import com.example.checkin.vn.util.Contants;

/**
 * Author: ZhuWenWu Version V1.0 Date: 2014/9/4 17:30. Description: Modification
 * History: Date Author Version Description
 * --------------------------------------
 * --------------------------------------------- 2014/9/4 ZhuWenWu 1.0 1.0 Why &
 * What is modified:
 */
public class HotelDetailtActivity extends SherlockFragmentActivity {

	private PullToZoomScrollView scrollView;
	private Button btnChitiet;
	private Button btnHangphong;
	private Button btnBinhluan;
	private ProgressBar loaddingTab;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setTheme(R.style.Theme_Styled_Detailt);
		requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
		super.onCreate(savedInstanceState);
		getSupportActionBar().setBackgroundDrawable(
				getResources().getDrawable(R.drawable.ab_bg_black));
		getSupportActionBar().setTitle("");
		setContentView(R.layout.activity_pull_to_zoom_scroll_view);
		new CountDownTimer(1000 * 1, 1000) {

			@Override
			public void onTick(long millisUntilFinished) {
			}

			@Override
			public void onFinish() {
				init();
				loaddingTab.setVisibility(View.GONE);
				FragmentManager fragmentManager = getSupportFragmentManager();
				FragmentTransaction ft = fragmentManager.beginTransaction();
				Fragment fragment = null;

				fragment = (Fragment) fragmentManager
						.findFragmentByTag(Contants.TAG_CHITIET);
				if (fragment == null) {
					fragment = new FragmentChitiet();
					ft.replace(R.id.frame_content_hotel_detailt, fragment,
							Contants.TAG_CHITIET);
				} else {
					ft.show(fragment);
				}

				ft.commit();

			}
		}.start();

	}

	public void init() {
		scrollView = (PullToZoomScrollView) findViewById(R.id.scroll_view);
		scrollView.setParallax(false);
		loaddingTab = (ProgressBar) findViewById(R.id.loadding_tab);
		btnChitiet = (Button) findViewById(R.id.btnChitiet);
		btnBinhluan = (Button) findViewById(R.id.btnBinhluan);
		btnHangphong = (Button) findViewById(R.id.btnHangphong);

		btnChitiet.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (!btnChitiet.isSelected()) {
					btnChitiet.setSelected(true);
					btnHangphong.setSelected(false);
					btnBinhluan.setSelected(false);
				}
			}
		});
		btnChitiet.setSelected(true);

		btnHangphong.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (!btnHangphong.isSelected()) {
					btnChitiet.setSelected(false);
					btnHangphong.setSelected(true);
					btnBinhluan.setSelected(false);
				}
			}
		});

		btnBinhluan.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (!btnBinhluan.isSelected()) {
					btnChitiet.setSelected(false);
					btnHangphong.setSelected(false);
					btnBinhluan.setSelected(true);
				}
			}
		});
	}

	private void loadViewForCode() {
		PullToZoomScrollView scrollView = (PullToZoomScrollView) findViewById(R.id.scroll_view);
		View headView = LayoutInflater.from(this).inflate(
				R.layout.profile_head_view, null, false);
		View zoomView = LayoutInflater.from(this).inflate(
				R.layout.profile_zoom_view, null, false);
		View contentView = LayoutInflater.from(this).inflate(
				R.layout.profile_head_view, null, false);
		scrollView.setHeaderContainer(headView);
		scrollView.setZoomView(zoomView);
		scrollView.setContentContainerView(contentView);
	}
}
